<?php

namespace JLPay\Models\Openmerch\Bill;

/**
 * 账单明细信息
 * 
 * @author liaochangyi
 * @since 2025-01-25
 */
class BillDetail
{
    protected ?string $startBusiDate = null;  // 开始营业日期，yyyy-MM-dd
    protected ?string $endBusiDate = null;  // 结束营业日期，yyyy-MM-dd
    protected ?string $billDate = null;  // 结算时间，yyyy-MM-dd
    protected ?string $remark = null;  // 备注，付款失败原因
    protected ?string $payStatus = null;  // 付款状态：0-待付款 1-付款成功 2-付款失败 3-无需付款
    protected ?string $payAmt = null;  // 付款金额
    protected ?string $transCount = null;  // 交易笔数
    protected ?string $settleAccount = null;  // 结算账户
    protected ?string $refundAmount = null;  // 退票金额，单位：分
    protected ?string $returnDate = null;  // 退票日期
    protected ?string $returnReason = null;  // 退票原因
    protected ?string $accountNo = null;  // 退票卡号

    /**
     * 构造函数
     *
     * @param array|null $detailDict 明细字典
     */
    public function __construct(?array $detailDict = null)
    {
        if ($detailDict) {
            $this->startBusiDate = $detailDict['start_busi_date'] ?? null;
            $this->endBusiDate = $detailDict['end_busi_date'] ?? null;
            $this->billDate = $detailDict['bill_date'] ?? null;
            $this->remark = $detailDict['remark'] ?? null;
            $this->payStatus = $detailDict['pay_status'] ?? null;
            $this->payAmt = $detailDict['pay_amt'] ?? null;
            $this->transCount = $detailDict['trans_count'] ?? null;
            $this->settleAccount = $detailDict['settle_account'] ?? null;
            $this->refundAmount = $detailDict['refund_amount'] ?? null;
            $this->returnDate = $detailDict['return_date'] ?? null;
            $this->returnReason = $detailDict['return_reason'] ?? null;
            $this->accountNo = $detailDict['account_no'] ?? null;
        }
    }

    /**
     * 获取开始营业日期
     *
     * @return string|null
     */
    public function getStartBusiDate(): ?string
    {
        return $this->startBusiDate;
    }

    /**
     * 获取结束营业日期
     *
     * @return string|null
     */
    public function getEndBusiDate(): ?string
    {
        return $this->endBusiDate;
    }

    /**
     * 获取结算时间
     *
     * @return string|null
     */
    public function getBillDate(): ?string
    {
        return $this->billDate;
    }

    /**
     * 获取付款状态
     *
     * @return string|null
     */
    public function getPayStatus(): ?string
    {
        return $this->payStatus;
    }

    /**
     * 获取付款金额
     *
     * @return string|null
     */
    public function getPayAmt(): ?string
    {
        return $this->payAmt;
    }

    /**
     * 获取交易笔数
     *
     * @return string|null
     */
    public function getTransCount(): ?string
    {
        return $this->transCount;
    }

    /**
     * 转换为数组格式
     *
     * @return array
     */
    public function toArray(): array
    {
        return [
            'start_busi_date' => $this->startBusiDate,
            'end_busi_date' => $this->endBusiDate,
            'bill_date' => $this->billDate,
            'remark' => $this->remark,
            'pay_status' => $this->payStatus,
            'pay_amt' => $this->payAmt,
            'trans_count' => $this->transCount,
            'settle_account' => $this->settleAccount,
            'refund_amount' => $this->refundAmount,
            'return_date' => $this->returnDate,
            'return_reason' => $this->returnReason,
            'account_no' => $this->accountNo
        ];
    }
} 